<?php
namespace app\api\controller;

use app\api\basic\BaseController;
use app\parkGuidance\logic\ParkGuidanceLogic;
use app\api\annotation\LoginRequired;
use support\Request;
class ParkguidanceController extends BaseController
{
     protected $userInfo;

    /**
     * 当前登陆管理员ID
     */
    protected $userId;

    /**
     * 当前登陆管理员账号
     */
    protected $userName;
    public function __construct()
    {   
        parent::__construct();
        $this->userId=request()->userId;
        $this->userName=request()->userName;
        $this->userInfo=request()->userInfo;
    }
    /**
     * 园区引导列表
     */
    #[LoginRequired(required: false)]
    public  function  lists(Request $request){
        $param = $request->more([
            ['lang_code','zh'],
            ['keyword',''],
            ['limit',10],
            ['page',1],
        ]);
      //  $where['lang_code']=$param['lang_code'];
        $guidance=new ParkGuidanceLogic();
        $query=$guidance->search([
            'lang_code'=>$param['lang_code'],
        ]);

        if($param['keyword']){
            $query->where('guidance_title|guidance_details', 'like', "%{$param['keyword']}%");

        }

        $guidanceData=$query
            ->whereNull('delete_time')
            ->field('guidance_id,guidance_icon,guidance_title')

            ->order('sort_order desc')
            ->order('create_time desc')
            ->paginate($param['limit']);
        return $this->success(['data'=>$guidanceData->items(),'total'=>$guidanceData->total()]);
    }

    /**
     * 园区引导详情
     * @param Request $request
     * @return \support\Response
     */
    #[LoginRequired(required: false)]
    public  function  parkinfo(Request $request){
        $param = $request->more([
            ['lang_code','zh'],
        ]);
        $where['lang_code']=$param['lang_code'];
        $guidance=new ParkGuidanceLogic();
        $guidanceData=$guidance
            ->search($where)
            ->whereNull('delete_time')
            ->find();
        return $this->success(['data'=>$guidanceData]);
    }


















}